﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.IO;
using System.Drawing.Imaging;
using System.Data.SqlClient;
using System.Configuration;
using System.Data.Sql;
using System.Data.SqlTypes;
using System.Web.SessionState;
using System.ComponentModel;
using System.Data;
using System.Web.UI.HtmlControls;


namespace iResume
{
    public partial class recruiterUpdateJob : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                

                ArrayList RecruiterJobUpdate = new ArrayList();
                string email = (string)(Session["username"]);
                string jobID = (string)(Session["jobID"]);
                if (email == null)
                {
                    Response.Redirect("loginpage.aspx");
                }
                RecruiterJobUpdate = DBManager.retrieveJobPostRecruiter(jobID,email);
                Recruiter rJobUpdate = new Recruiter();
                rJobUpdate = (Recruiter)RecruiterJobUpdate[0];
                Image1.ImageUrl = "recruiterDisplayImage.ashx?id=" + email;
                jobID1.Text = rJobUpdate.JobID;
                Name.Text = rJobUpdate.CompanyName;
                Add.Text = rJobUpdate.CompanyAddress;
                url.Text = rJobUpdate.CompanyURL;
                profile.Text = rJobUpdate.CompanyProfile;
                DropDownList2.Text = rJobUpdate.SalaryRange.ToString();
                tbxJobPosition.Text = rJobUpdate.JobPosition;
                DropDownList1.Text = rJobUpdate.Category.ToString();
                tbxJobDescription.Text = rJobUpdate.JobDescription;
                DropDownList3.Text = rJobUpdate.VacancyAvabile.ToString();
                jname.Text = rJobUpdate.PersonInCharge;
                eemail.Text = rJobUpdate.Email;
                contact.Text = rJobUpdate.ContactNum;

              
            }
        }



        protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
        {
            string username = (string)(Session["username"]);
            //string password = (string)(Session["password"]);


            string companyName = Name.Text;
            string companyAddress = Add.Text;
            string companyProfile = profile.Text;
            string companyURL = url.Text;
            string salaryRange = DropDownList2.SelectedItem.Text;
            string jobPosition = tbxJobPosition.Text;
            string category = DropDownList1.SelectedItem.Text;
            string jobDescription = tbxJobDescription.Text;
            string personIncharge = jname.Text;
            string email = eemail.Text;
            string contactNum = contact.Text;
            string vacancyAvabile = DropDownList3.Text;
            string jobID = jobID1.Text;


            Recruiter r = new Recruiter(username, salaryRange, jobPosition, category, jobDescription, vacancyAvabile, jobID);

            DBManager.updateJobPostRecruiter(r);

            DropDownList2.Text = "";
            tbxJobPosition.Text = "";
            DropDownList1.Text = "";
            tbxJobDescription.Text = "";
            DropDownList3.Text = "";


            Response.Redirect("recruiterViewPostJob.aspx");
        }
    }
}